﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using System.Data.SqlClient;
using lakethaiClassLibrary;

public partial class home_Default : BasePage
{
    protected string welcomeTitle = string.Empty, welcomeDetails = string.Empty;
    protected string productList = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = Resources.header.homepageTitle;
        this.BindingData();
        this.GetWelcomeContent();
    }
    private void BindingData()
    {
        string lang = HttpContext.Current.Session["lancode"].ToString();
        #region get-product-list
        SqlParameter[] param1 = { new SqlParameter("lang", lang) };
        DataTable dt = myDataBinding.GetData("_productGetTopHotForShow", param1);
        if (dt == null || dt.Rows.Count <= 0) return;
        StringBuilder sb = new StringBuilder();
        foreach (DataRow row in dt.Rows)
        {
            sb.Append("<div class=\"line\"></div>");
            sb.Append("<div class=\"block\">");
            sb.Append("<img src=\"" + row[1].ToString()
                + "\" alt=\"\" title=\"" + row[2].ToString() + "\" />");
            sb.Append("<a href=\"../P" + row[0].ToString() + "/"
                + myHelp.createURLString(row[2].ToString()) + ".aspx\"");
            sb.Append("class=\"newsTitle\">" + row[2].ToString() + "</a>");
            sb.Append("<span class=\"datetime-span\">");
            sb.Append("<p>" + row[3].ToString() + "</p>");
            sb.Append("<a href=\"../P" + row[0].ToString() + "/"
                + myHelp.createURLString(row[2].ToString()) + ".aspx\"");
            sb.Append("class=\"newsDetail\">");
            if (lang.CompareTo("en") == 0)
                sb.Append("[Details]</a>");
            else
                sb.Append("[Chi tiết]</a>");
            sb.Append("</div>");//div block
        }
        this.productList = sb.ToString();
        #endregion
    }
    private void GetWelcomeContent()
    {
        SqlParameter[] param ={new SqlParameter("id","1"),
                                 new SqlParameter("lang",HttpContext.Current.Session["lancode"].ToString())
                             };
        DataTable dt = myDataBinding.GetData("_introductionGetItemForShow", param);
        try
        {
            this.welcomeTitle = dt.Rows[0][0].ToString();
            this.welcomeDetails = dt.Rows[0][1].ToString();
        }
        catch {}
    }
}
